{layout name="layout" /}

    <!-- Imported scripts on this page -->
    <script src="__STATIC__/js/rwd-table/js/rwd-table.min.js"></script>
    <script src="__STATIC__/js/datatables/js/jquery.dataTables.min.js"></script>

    <!-- <link rel="stylesheet" href="__STATIC__/css/xenon-forms.css"> -->

    <!-- Imported scripts on this page -->
    <script src="__STATIC__/js/datatables/dataTables.bootstrap.js"></script>
    <script src="__STATIC__/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
    <script src="__STATIC__/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

    <script src="__STATIC__/js/table-export/xlsx.core.min.js"></script>
    <script src="__STATIC__/js/table-export/blob.js"></script>
    <script src="__STATIC__/js/table-export/FileSaver.min.js"></script>
    <script src="__STATIC__/js/table-export/tableexport.js"></script>

<div class="page-title">  
    
    <div class="breadcrumb-env pull-left">
        
        <ol class="breadcrumb bc-1">
            <li>
                <a href="{:url('Order/index')}"><i class="fa-home"></i>首页</a>
            </li>
            <li>
                <a href="">订单管理</a>
             </li>
            <li class="active">
                <strong>理货管理</strong>
            </li>
        </ol>
                    
    </div>       
</div>



<div class="row">
                <div class="col-md-12">
                

<!-- ******************************************************************************************************** -->      

            
            <!-- Removing search and results count filter -->
            <div class="panel panel-default">
                <div class="panel-heading btn-toolbar">
                    <h3 class="panel-title">理货管理</h3>

                    <div class="btn-group dropdown-btn-group pull-right">
                        <button class="btn btn-default" onClick ="$('.table').tableExport({formats:['xlsx','xls','csv','txt']})">导出</button>
                    </div>                    

                </div>
                <div class="panel-body">
                    

        
    

                    <!-- searach -->
                    <div class="btn-toolbar">

                        <form class="form-inline" style="margin-bottom:15px;" class="search-tool">
<!--                             <span>
                                <label class="control-label">产品编号</label>   
                                <input type="text" class="form-control" placeholder="产品编号" name="product_no" value="{$Request.get.product_no}"> 
                            </span> -->
                            
                            <span style="margin-left: 15px;">
                                <label class="control-label">订单编号</label>      
                                <input type="text" class="form-control" placeholder="订单编号" name="sn" value="{$Request.get.sn}">
                            </span>

                            <span style="margin-left: 15px;">
                                <label class="control-label">收件人</label>      
                                <input type="text" class="form-control" placeholder="收件人" name="receiver_name" value="{$Request.get.receiver_name}">
                            </span>

                            <span style="margin-left: 15px;">
                                <label class="control-label">订单状态</label>
                                <select class="form-control" name="tally_status">
                                    <option value="" 
                                        {eq name="Request.get.tally_status" value=" "} selected="selected" {/eq}
                                    >全部</option>
                                    <option value="0" 
                                        {eq name="Request.get.tally_status" value="0"} selected="selected" {/eq}
                                    >未理货</option>
                                    <option value="1" 
                                        {eq name="Request.get.tally_status" value="1"} selected="selected" {/eq}
                                    >已挂起</option>
                                    <option value="1" 
                                        {eq name="Request.get.tally_status" value="2"} selected="selected" {/eq}
                                    >已理货</option>
                                </select>   
                            </span>

                            <span style="margin-left: 15px;">
                                <button class="btn btn-default btn-primary" type="submit" style="margin-top:10px;">
                                    <span class="fa-search"></span> 搜 索
                                </button> 
                            </span>
                        
                        </form>
                        
                    </div>
                    <!-- searach -->


                    <script type="text/javascript">
                    jQuery(document).ready(function($)
                    {
                        $("#example-2").dataTable({
                            dom: "t" + "<'row'<'col-xs-6'i><'col-xs-6'p>>",
                            dom: "t" + "<'row'<'col-xs-6'><'col-xs-6'>>",
                            aoColumns: [
                                // {bSortable: false},
                                null,
                                null,
                                null,
                                null,
                                null,
                                null,
                                null,
                                {bSortable: false}
                            ],
                        });
                        
                        // Replace checkboxes when they appear
                        var $state = $("#example-2 thead input[type='checkbox']");
                        
                        $("#example-2").on('draw.dt', function()
                        {
                            cbr_replace();
                            
                            $state.trigger('change');
                        });
                        
                        // Script to select all checkboxes
                        $state.on('change', function(ev)
                        {
                            var $chcks = $("#example-2 tbody input[type='checkbox']");
                            
                            if($state.is(':checked'))
                            {
                                $chcks.prop('checked', true).trigger('change');
                            }
                            else
                            {
                                $chcks.prop('checked', false).trigger('change');
                            }
                        });
                    });
                    </script>
                    

                    <table class="table table-bordered table-striped" id="example-2">
                        <thead>
                            <tr>
<!--                                 <th class="no-sorting">
                                    <input type="checkbox" class="cbr">
                                </th> -->
                                <th>ID</th>
                                <th>电商订单号</th>
                                <th>产品编码</th>
                                <th>订单来源</th>
                                <th>订单名称</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        
                        <tbody class="middle-align">
                        
                        {volist name='list' id='vo'}
                            <tr>
<!--                                 <td>
                                    <input type="checkbox" class="cbr">
                                </td> -->
                                <td> {$vo.rec_id} </td>
                                <td> {$vo.order_sn} </td>
                                <td> {$vo.order_sn} </td>
                                <td> {$vo.referer == '' ?'暂无':$vo.referer} </td>
                                <td> {$vo.receiver_name} </td>
                                <td>
                                    {if condition="$vo.tally_status eq 0 "} 
                                        未理货
                                    {elseif condition="$vo.tally_status eq 1 "/}
                                        挂起
                                    {else /} 
                                        已理货
                                    {/if}
                                </td>
                                <td> {:date('Y-m-d H:i:s',$vo->add_time)} </td>
                                <td>
                                    <a href="javascript:;" 
                                        class="btn btn-secondary btn-sm btn-icon icon-left" 
                                        onclick="editAjaxModal('{$vo->rec_id}',1)" >
                                        挂起
                                    </a>
                                {if condition="$vo.tally_status eq 0"}
                                    <a href="javascript:;" 
                                        class="btn btn-secondary btn-sm btn-icon icon-left" 
                                        onclick="editAjaxModal('{$vo->rec_id}',2)" >
                                        理货
                                    </a>
                                {elseif condition="$vo.tally_status eq 1"/}
                                    <a href="javascript:;" 
                                        class="btn btn-danger btn-sm btn-icon icon-left" 
                                        onclick="editAjaxModal('{$vo->rec_id}',0)" >
                                        已挂起
                                    </a>
                                {else /}
                                    <a href="javascript:;" 
                                        class="btn btn-danger btn-sm btn-icon icon-left" 
                                        onclick="editAjaxModal('{$vo->rec_id}',0)" >
                                        取消
                                    </a>
                                {/if}

                                    
<!--                                     <a ref="javascript:;" class="btn btn-danger btn-sm btn-icon icon-left" onclick="del('{$vo.rec_id}')">
                                        删除
                                    </a> -->

                                </td>
                            </tr>
                        {/volist}

                        </tbody>
                    </table>

                    <div class="row">
                        <div class="col-xs-6">
                            <div class="dataTables_info" id="example-3_info" role="status" aria-live="polite"> 共{:count( $list ) } 行数据</div></div>
                        <div class="col-xs-6">
                            <div class="dataTables_paginate paging_simple_numbers" id="example-3_paginate">
                                {$list->render()}
                            </div>
                        </div>
                    </div>                  

                </div>
            </div>

   

<script type="text/javascript">

    //edit
    function editAjaxModal(id,status){
        var res = {'id':id,status:status};

        $.post("{:url('Pack/arrangeAdd')}", res,function(data){
            if( data.error>0 ){
                toastr.error( data.msg );  
            }else{
                toastr.success( data.msg );  
                location.reload();
            }
        }, "json");
    }


    //del
    // function del(id){
    //     if( confirm("确定要删除吗？") ){
    //         $.post("{:url('Order/delete')}", {id:id},function(data){
    //             if( data.error>0 ){
    //                 toastr.error( data.msg );  
    //             }else{
    //                 toastr.success( data.msg );  
    //                 location.reload();
    //             }
    //         }, "json");
    //     } 

    // }
</script>